package com.kfy.databinding4;

import android.text.TextUtils;
import android.util.Log;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

/**
 * @ProjectName: JetpackDemo
 * @Package: com.kfy.databinding4
 * @Author: K.F.Y
 * @Date: 2022/4/28
 */
public class UserViewModel  extends BaseObservable {

    private User user;

    public UserViewModel(){
        this.user = new User("KeFuYou");
    }

    @Bindable
    public String getUserName() {
        return user.username;
    }

    public void setUserName(String userName){
        if (userName != null && !userName.equals(user.username)) {
            user.username = userName;
            Log.d("KFYTEST","set username : " + userName);
            notifyPropertyChanged(BR.userName);
        }
    }
}
